<%@page import="com.shsh.safemanage.model.Problem"%>
<%@page import="com.shsh.safemanage.util.ActionUtil"%>
<%@page import="com.shsh.safemanage.model.ProblemHSECategory"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.dao.HSEProblemDao"%>
<%@page import="com.shsh.safemanage.util.Constants"%>
<%@page import="com.shsh.safemanage.model.HSECategory"%>
<%@page import="java.util.List"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.dao.ProblemDao"%>

<%
{
HSEProblemDao theHseProblemDao = DaoCreator.createHSEProblemDao();

Boolean isReadonly = (Boolean) request.getAttribute(Constants.REQUEST_ATTRIBUTE_IS_READONLY);
List<ProblemHSECategory> theProblemHSECategoryList = (List<ProblemHSECategory>) request.getAttribute(Constants.REQUEST_ATTRIBUTE_PROBLEM_HSE_CATEGORY_LIST);
Problem theHSEProblem = (Problem) request.getAttribute(Constants.REQUEST_ATTRIBUTE_PROBLEM);
%>
<span style="margin-left: 40px" class="span1">问题分类：</span>
<br />
<table width="75%" border="1" style="margin-left: 70px">
	<tr>
		<td class="td1" align="center" width="50%">人员的位置</td>
		<td class="td1" align="center">个人防护装备配备或使用不当</td>
	</tr>
	<%
	List<HSECategory> categoryList = theHseProblemDao.getHSECategoryList(null);
	%>
	<tr>
		<td class="td1">
		<%
		for (HSECategory hseCategory : categoryList) {
			if (hseCategory.getCategoryType() != Constants.HSE_CATEGORY_TYPE_PERSON_POSITION) {
				continue;
			}
			
			ProblemHSECategory theProblemHSECategory = null;
			if (theHSEProblem != null && theProblemHSECategoryList != null) {
				theProblemHSECategory = ActionUtil.problemHSECategoryExistsIn(theHSEProblem.getId(), hseCategory.getId(), 
					hseCategory.getCategoryType(), theProblemHSECategoryList);
			}
		%>
			<input type="checkbox" name="categoryPerPos" id="categoryPerPos<%=hseCategory.getId()%>" value="<%=hseCategory.getId()%>"
				<%=(isReadonly != null && isReadonly)? "onclick=\"this.checked=!this.checked\"":
					"onclick=\"singleCheckboxes('categoryPerPos','categoryPerPos"+hseCategory.getId()+"', true)\"" %>
				<%=(theProblemHSECategory != null)? "checked":"" %> />
			<label for="categoryPerPos<%=hseCategory.getId()%>"><%=hseCategory.getCategoryName()%></label>
		<%
			if (hseCategory.isOther()) {
		%>
			<input type="text" id="categoryPerPosOther" value="<%=(theProblemHSECategory != null)? theProblemHSECategory.getOther():"" %>"
				<%=(isReadonly != null && isReadonly)? "readonly":
					"onfocus=\"singleCheckboxes('categoryPerPos','categoryPerPos"+hseCategory.getId()+"', false)\"" %> />
		<%
			}
		%>
			<br />
		<%
		}
		%>
		</td>
		<td class="td1">
		<%
		for (HSECategory hseCategory : categoryList) {
			if (hseCategory.getCategoryType() != Constants.HSE_CATEGORY_TYPE_DEFENSIVE_EQUIP) {
				continue;
			}
			
			ProblemHSECategory theProblemHSECategory = null;
			if (theHSEProblem != null && theProblemHSECategoryList != null) {
				theProblemHSECategory = ActionUtil.problemHSECategoryExistsIn(theHSEProblem.getId(), hseCategory.getId(), 
					hseCategory.getCategoryType(), theProblemHSECategoryList);
			}
		%>
			<input type="checkbox" name="categoryPerEquip" id="categoryPerEquip<%=hseCategory.getId()%>" value="<%=hseCategory.getId()%>"
				<%=(isReadonly != null && isReadonly)? "onclick=\"this.checked=!this.checked\"":
					"onclick=\"singleCheckboxes('categoryPerEquip','categoryPerEquip"+hseCategory.getId()+"', true)\"" %> 
				<%=(theProblemHSECategory != null)? "checked":"" %> />
			<label for="categoryPerEquip<%=hseCategory.getId()%>"><%=hseCategory.getCategoryName()%></label>
		<%
			if (hseCategory.isOther()) {
		%>
			<input type="text" id="categoryPerEquipOther" value="<%=(theProblemHSECategory != null)? theProblemHSECategory.getOther():"" %>"
				<%=(isReadonly != null && isReadonly)? "readonly":
					"onfocus=\"singleCheckboxes('categoryPerEquip','categoryPerEquip"+hseCategory.getId()+"', false)\"" %> />
		<%
			}
		%>
			<br />
		<%
		}
		%>
		</td>
	</tr>
	<tr>
		<td class="td1" align="center">作业行为</td>
		<td class="td1" align="center">工具及设备</td>
	</tr>
	<tr>
		<td class="td1" rowspan="3">
		<%
		for (HSECategory hseCategory : categoryList) {
			if (hseCategory.getCategoryType() != Constants.HSE_CATEGORY_TYPE_WORK_ACTIVITY) {
				continue;
			}
			
			ProblemHSECategory theProblemHSECategory = null;
			if (theHSEProblem != null && theProblemHSECategoryList != null) {
				theProblemHSECategory = ActionUtil.problemHSECategoryExistsIn(theHSEProblem.getId(), hseCategory.getId(), 
					hseCategory.getCategoryType(), theProblemHSECategoryList);
			}
		%>
			<input type="checkbox" name="categoryWorkAct" id="categoryWorkAct<%=hseCategory.getId()%>" value="<%=hseCategory.getId()%>"
				<%=(isReadonly != null && isReadonly)? "onclick=\"this.checked=!this.checked\"":"" %> 
				<%=(theProblemHSECategory != null)? "checked":
					"onclick=\"singleCheckboxes('categoryWorkAct','categoryWorkAct"+hseCategory.getId()+"', true)\"" %> />
			<label for="categoryWorkAct<%=hseCategory.getId()%>"><%=hseCategory.getCategoryName()%></label>
		<%
			if (hseCategory.isOther()) {
		%>
			<input type="text" id="categoryWorkActOther" value="<%=(theProblemHSECategory != null)? theProblemHSECategory.getOther():"" %>"
				<%=(isReadonly != null && isReadonly)? "readonly":
					"onfocus=\"singleCheckboxes('categoryWorkAct','categoryWorkAct"+hseCategory.getId()+"', false)\"" %> />
		<%
			}
		%>
			<br />
		<%
		}
		%>
		</td>
		<td class="td1">
		<%
		for (HSECategory hseCategory : categoryList) {
			if (hseCategory.getCategoryType() != Constants.HSE_CATEGORY_TYPE_TOOL_EQUIP) {
				continue;
			}
			
			ProblemHSECategory theProblemHSECategory = null;
			if (theHSEProblem != null && theProblemHSECategoryList != null) {
				theProblemHSECategory = ActionUtil.problemHSECategoryExistsIn(theHSEProblem.getId(), hseCategory.getId(), 
					hseCategory.getCategoryType(), theProblemHSECategoryList);
			}
		%>
			<input type="checkbox" name="categoryToolEquip" id="categoryToolEquip<%=hseCategory.getId()%>" value="<%=hseCategory.getId()%>"
				<%=(isReadonly != null && isReadonly)? "onclick=\"this.checked=!this.checked\"":"" %> 
				<%=(theProblemHSECategory != null)? "checked":
					"onclick=\"singleCheckboxes('categoryToolEquip','categoryToolEquip"+hseCategory.getId()+"', true)\"" %> />
			<label for="categoryToolEquip<%=hseCategory.getId()%>"><%=hseCategory.getCategoryName()%></label>
		<%
			if (hseCategory.isOther()) {
		%>
			<input type="text" id="categoryToolEquipOther" value="<%=(theProblemHSECategory != null)? theProblemHSECategory.getOther():"" %>"
				<%=(isReadonly != null && isReadonly)? "readonly":
					"onfocus=\"singleCheckboxes('categoryToolEquip','categoryToolEquip"+hseCategory.getId()+"', false)\"" %> />
		<%
			}
		%>
			<br />
		<%
		}
		%>
		</td>
	</tr>
	<tr>
		<td class="td1" align="center">作业场所与环境</td>
	</tr>
	<tr>
		<td class="td1">
		<%
		for (HSECategory hseCategory : categoryList) {
			if (hseCategory.getCategoryType() != Constants.HSE_CATEGORY_TYPE_WORK_ENVIRONMENT) {
				continue;
			}
			
			ProblemHSECategory theProblemHSECategory = null;
			if (theHSEProblem != null && theProblemHSECategoryList != null) {
				theProblemHSECategory = ActionUtil.problemHSECategoryExistsIn(theHSEProblem.getId(), hseCategory.getId(), 
					hseCategory.getCategoryType(), theProblemHSECategoryList);
			}
		%>
			<input type="checkbox" name="categoryWorkEnv" id="categoryWorkEnv<%=hseCategory.getId()%>" value="<%=hseCategory.getId()%>"
				<%=(isReadonly != null && isReadonly)? "onclick=\"this.checked=!this.checked\"":"" %> 
				<%=(theProblemHSECategory != null)? "checked":
					"onclick=\"singleCheckboxes('categoryWorkEnv','categoryWorkEnv"+hseCategory.getId()+"', true)\"" %> />
			<label for="categoryWorkEnv<%=hseCategory.getId()%>"><%=hseCategory.getCategoryName()%></label>
		<%
			if (hseCategory.isOther()) {
		%>
			<input type="text" id="categoryWorkEnvOther" value="<%=(theProblemHSECategory != null)? theProblemHSECategory.getOther():"" %>"
				<%=(isReadonly != null && isReadonly)? "readonly":
					"onfocus=\"singleCheckboxes('categoryWorkEnv','categoryWorkEnv"+hseCategory.getId()+"', false)\"" %> />
		<%
			}
		%>
			<br />
		<%
		}
		%>
		</td>
	</tr>
</table>
<%
}
%>